package service;

import util.string.GetNowDate;
import dao.AdminDao;
import entity.Admin;

public class AdminService {

	AdminDao adminDao = new AdminDao();
	
	public Admin login(String username, String password, String ip) {
		Admin admin = adminDao.findAdminByUsername(username);
		if (admin != null && admin.getPassword().equals(password)) {
			admin.setIp(ip);
			admin.setLastaccesstime(GetNowDate.getNow());
			adminDao.update(admin);
			return admin;
		}
		return null;
	}

	public void update(Admin admin) {
		adminDao.update(admin);
	}

	
	
}
